/*
 * @Author: 高瑞寒 15932717091@163.com
 * @Date: 2022-04-15 16:11:33
 * @LastEditTime: 2022-04-15 17:25:16
 * @LastEditors: 高瑞寒 15932717091@163.com
 * @Description:
 */
import { formatDate } from '@/filters'
/**
 * 导入数据对应表
 */
export const USER_RELATIONS = {
  姓名: 'username',
  联系方式: 'mobile',
  角色: 'role',
  开通时间: 'openTime'
}
// formatJson
export const formatJson = (header, rows) => {
  return rows.map(item => {
    return Object.keys(header).map(key => {
      if (header[key] === 'role') {
        const roles = item[header[key]]
        return JSON.stringify(roles.map(role => role.title))
      }
      if (header[key] === 'openTime') {
        return formatDate(item[header[key]])
      }
      return item[header[key]]
    })
  })
}
